using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using SJXmlP.XMLClasses;
using System;
using System.Reflection;
using System.Text;

namespace yW5Lib
{
	public class clsCharacter : clsBase
	{
		private string mvarFullName;

		private bool mvarMajor;

		private string mvarBio;

		private string mvarGoals;

		private int mvarVPSceneCount;

		private int mvarSceneCount;

		private int mvarWordCount;

		private int mvarVPSceneCountUnused;

		public const string ObjectName = "Character";

		public bool AddedToProject;

		public bool Major
		{
			get
			{
				return mvarMajor;
			}
			set
			{
				mvarMajor = value;
			}
		}

		public int SceneCount
		{
			get
			{
				return mvarSceneCount;
			}
			set
			{
				mvarSceneCount = value;
			}
		}

		public int VPSceneCount
		{
			get
			{
				return mvarVPSceneCount;
			}
			set
			{
				mvarVPSceneCount = value;
			}
		}

		public int VPSceneCountUnused
		{
			get
			{
				return mvarVPSceneCountUnused;
			}
			set
			{
				mvarVPSceneCountUnused = value;
			}
		}

		public int WordCount
		{
			get
			{
				return mvarWordCount;
			}
			set
			{
				mvarWordCount = value;
			}
		}

		public string Bio
		{
			get
			{
				return mvarBio;
			}
			set
			{
				mvarBio = value;
			}
		}

		public string Goals
		{
			get
			{
				return mvarGoals;
			}
			set
			{
				mvarGoals = value;
			}
		}

		public string FullName
		{
			get
			{
				return mvarFullName;
			}
			set
			{
				mvarFullName = value;
			}
		}

		public clsCharacter()
		{
			mvarFullName = "";
			mvarBio = "";
			mvarGoals = "";
		}

		public void Clear()
		{
			BaseClear();
			mvarBio = "";
			mvarGoals = "";
			mvarMajor = false;
			mvarFullName = "";
		}

		public string DataAsXML()
		{
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				string str = "\t\t";
				stringBuilder.AppendLine("\t<CHARACTER>");
				stringBuilder.Append(BaseDataAsXML());
				if (mvarBio.Length > 0)
				{
					string value = str + cXml.EncloseCData(mvarBio, "<Bio>", "</Bio>");
					stringBuilder.AppendLine(value);
				}
				if (mvarGoals.Length > 0)
				{
					string value = str + cXml.EncloseCData(mvarGoals, "<Goals>", "</Goals>");
					stringBuilder.AppendLine(value);
				}
				if (mvarFullName.Length > 0)
				{
					string value = str + cXml.EncloseCData(mvarFullName, "<FullName>", "</FullName>");
					stringBuilder.AppendLine(value);
				}
				if (mvarMajor)
				{
					string value = str + cXml.EncloseBool(mvarMajor, "<Major>", "</Major>");
					stringBuilder.AppendLine(value);
				}
				stringBuilder.AppendLine("\t</CHARACTER>");
				return stringBuilder.ToString();
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				string result = "";
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}

		public bool CreateFromXML(string XMLData)
		{
			bool result = false;
			try
			{
				Clear();
				if (!BaseCreateFromXML(XMLData))
				{
					return result;
				}
				mvarMajor = cXml.ExtractBool(XMLData, "<Major>", "</Major>");
				mvarFullName = cXml.ExtractCData(XMLData, "<FullName>", "</FullName>");
				mvarBio = cXml.ExtractCData(XMLData, "<Bio>", "</Bio>");
				mvarGoals = cXml.ExtractCData(XMLData, "<Goals>", "</Goals>");
				if (Operators.CompareString(mvarAKA.Trim(), "", TextCompare: false) == 0)
				{
					mvarAKA = cXml.ExtractCData(XMLData, "<AlternateNames>", "</AlternateNames>");
				}
				result = true;
				return result;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}
	}
}
